home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15231 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.th-darmstadt.de!news
  2. From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: delete or delete [] ?
  5. Date: 02 Apr 1996 20:21:25 +0200
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Sender: enno@kitz.inferenzsysteme.informatik.th-darmstadt.de
  8. Message-ID: <ltn34uwkpm.fsf@kitz.inferenzsysteme.informatik.th-darmstadt.de>
  9. References: <4jp7n7$f8k@mcmail.CIS.McMaster.CA>
  10. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  11. In-reply-to: g9326161@mcmail.cis.McMaster.CA's message of 1 Apr 1996 13:36:23
  12.     -0500
  13. X-Newsreader: Gnus v5.1
  14.  
  15. In article <4jp7n7$f8k@mcmail.CIS.McMaster.CA> g9326161@mcmail.cis.McMaster.CA (Hong Shen) writes:
  16.  
  17.    In almost all of C++ literatures, "delete aa" should be used iff aa is not an 
  18.    array and "delete [] aa" should be used iff aa is an array. In following case,
  19.    what should I use?
  20.  
  21.    typedef int int10[10];
  22.    int* aa=new int10; // array of 10 integers.
  23.  
  24.    delete aa;
  25.  
  26.    or 
  27.  
  28.    delete [] aa;
  29.  
  30.    For gcc (v2.6), it seems that both work. Which is the standard one?
  31.  
  32. You're allocating an array of int's, thus 'delete[] aa;' is the right
  33. choice.
  34.  
  35.     Enno
  36.  
  37.  
  38.